<!DOCTYPE html>
<html lang="en">

<head>
    <link rel="stylesheet" href="__INDEX__/mobile/css/yysj.css">
    {include file="mobile/public/resource" /}
</head>

<body>
    {include file="mobile/public/header" /}
    <div class="banner" style="margin-top:3rem;"><img src="__INDEX__/mobile/img/dgsm/banner.png"></div>
    <div class="main">
        <div class="d_center">
            <img src="__INDEX__/mobile/img/cxzt/{$id}.png">
        </div>
    </div>
    <div class="banner">
        <input type="hidden" id="type" value="{$id}">
        <!-- <p id="m_p1"><span>*</span>为必选项。您的信息我们将会完全保密,请您放心填写</p> -->
        <div class="yy layui-form">
            <div class="sle1 sles">
                <span>请选择车系:</span>
                <select name="cx" id="cx">
                        {foreach name="cx" item="vo" }
                        <option value="{$vo['name']}">{$vo['name']}</option>
                        {/foreach}
                        <option value="奥铃专用车">奥铃专用车</option>
                    </select>
            </div>
            <div class="sle2 sles types">
                <span>所&nbsp;在&nbsp;城&nbsp;市:</span>
                <select name="province" id="province" lay-filter="getCity" lay-verify="province">
                        <option value="0">请选择省份</option>
                        {foreach name="province" item="vc" }
                        <option value="{$vc['id']}">{$vc['name']}</option>
                        {/foreach}
                    </select>
                    <select value="city" name="city" id="city" lay-filter="getJxs" lay-verify="city">
                        <option value="0">请选择城市</option>
                    </select>
            </div>
            <!-- <div class="sle3 sles">
                <span></span>
                <input type="text" class="layui-input" placeholder="车辆vin号">
                <input type="text" class="sel-right layui-input" placeholder="车牌号">
            </div> -->
<!--             <div class="sle4">
                            <span>经销商名称:</span>
                            <select name="" id="">
                                <option value="0">请选择</option>
                            </select>
                            <select name="" id="">
                                <option value="0">请选择</option>
                            </select>
                            <select name="" id="">
                                <option value="0">请选择</option>
                            </select>
                        </div> -->
            <!-- <div class="sle1 sles">
                <span>*经销商查询:</span>
               <select name="jxs" id="jxs" lay-verify="jxs" lay-filter="jxs">
                        <option value="0">请选择经销商</option>
                    </select>
            </div> -->
            <div class="sle5 sles">
                <span style="width: 10%;padding-left: 6.7%;">姓</span ><span style="width: 22%">名:</span>
               <input type="text" name="name" class="layui-input" required lay-verify="required" style="margin-right: 0%;">
                    <!-- <input type="radio" name="sex" value="先生" title="先生" checked>
                    <input type="radio" name="sex" value="女士" title="女士"> -->
            </div>
            <div class="sle6" style="width: 100%">
                <span>联&nbsp;系&nbsp;方&nbsp;式:&nbsp;</span>
              <input type="text" name="phone" class="layui-input" lay-verify="phone" style="margin-right: 0%;">
                <!-- <input type="text" class="layui-input" placeholder="区号">
                            
                            <input type="text" class="layui-input" placeholder="号码"> -->
            </div>
            <!-- <div class="sle7 sles">
                <span></span>
                <input type="text" class="layui-input" placeholder="微信">
                <span class="line" class="" style="text-align: center; margin-left: -2.375rem;">-</span>
                <input type="text" class="q layui-input" placeholder="QQ"
                    style="margin-left: -1.5625rem;margin-right: 1.25rem;">
            </div> -->
            <!-- <div class="sle8">
                <span>请描述您的需求:</span>
                <textarea name="" id="" cols="30" rows="10" class="layui-textarea"></textarea>
            </div> -->
            
            <!-- <div class="public public6">
                <span>*计划购车时间:</span>
                <input type="radio" name="sex" value="1" title="一周后" checked>
                <input type="radio" name="sex" value="1" title="半月后" checked>
                <input type="radio" name="sex" value="1" title="一月后" checked>
            </div>
            <div class="public public7">
                <span>*计划购车时间:</span>
                <input type="radio" name="sex" value="1" title="三个月后" checked>
                <input type="radio" name="sex" value="1" title="半年后" checked>
                <input type="radio" name="sex" value="1" title="一年后" checked>
            </div> -->
            
            <!-- <div class="sle9 sles">
                            <span>预约时间:</span>
                            <input type="date" class="layui-input">
                            <input type="text" class="sel-right layui-input">
                        </div> -->
            <button class="layui-btn" lay-submit lay-filter="tj">立即提交</button>

        </div>
    </div>

    {include file="mobile/public/footer" /}

    <script>
            $(document).ready(function () {
                var province, city, jxs;
                var type = $("#type").val();
                // $("#myCar").vc3dEye({
                //  imagePath:"images/",
                //  totalImages:51,
                //  imageExtension:"png"
                // });

                layui.use('form', function () {
                    var form = layui.form;

                    //各种基于事件的操作，下面会有进一步介绍
                    form.on('select(getCity)', function (data) {
                        province = $(this).text();
                        $.ajax({
                            type: 'POST',
                            dataType: 'json',
                            url: '{:url('Testdrive/getCity')}',
                            data: {
                                province: data.value,
                            },
                            success: function (data) {
                                var quname_html = "<option value='0'>请选择城市</option>";
                                for (var i = 0; i < data.length; i++) {
                                    quname_html += "<option value='" + data[i].id + "'>" +
                                        data[i].name + "</option>";
                                }
                                $("#city").html(quname_html);
                                form.render();
                            }
                        });
                    });


                    form.on('select(getJxs)', function (data) {
                        city = $(this).text();
                        $.ajax({
                            type: 'POST',
                            dataType: 'json',
                            url: '{:url('Testdrive/getjxs')}',
                            data: {
                                city: data.value,
                            },
                            success: function (data) {
                                var quname_html = "<option value='0'>请选择经销商</option>";
                                for (var i = 0; i < data.length; i++) {
                                    quname_html += "<option value='" + data[i].id + "'>" +
                                        data[i].name + "</option>";
                                }
                                $("#jxs").html(quname_html);
                                form.render();
                            }
                        });
                    });

                    form.on('select(jxs)', function (data) {
                        jxs = $(this).text();

                    });
                    //自定义验证规则  
                    form.verify({
                        province: function (value) {
                            if (value == 0) {
                                return '请选择省份';
                            }
                        },
                        city: function (value) {
                            if (value == 0) {
                                return '请选择城市';
                            }
                        },
                        jxs: function (value) {
                            if (value == 0) {
                                return '请选择经销商';
                            }
                        },
                        phone: [/^1[3|4|5|7|8]\d{9}$/, '手机必须11位，只能是数字！']
                    });



                    //监听提交
                    form.on('submit(tj)', function (data) {
                    
                        $.ajax({
                            type: 'POST',
                            dataType: 'json',
                            url: '{:url('Testdrive/tj')}',
                            data: {
                                cx: data.field.cx,
                                province: province,
                                city: city,
                                jxs: '',
                                name: data.field.name,
                                sex: '',
                                phone: data.field.phone,
                                time: '',
								type: type,
								brand: '',
								vin: '',
								cp: '',
								wx:'',
								qq:'',
								content:'',
								date:'',
								cx:''                           },
                            success: function (data) {
                                if (data == 1) {
                                    layer.msg('请等待客服人员与您联系', {
                                        icon: 6,
                                        time: 2000,
                                        end: function () {
                                            location.href = 'http://aoling.douyar.cc/';
                                        }
                                    });
                                }
                            }
                        });
                    });

                });
            });
        </script>
</body>

</html>